// 引入属性特规组件
document.write("<script type='text/javascript' src='/statics/js/modules/quoteProductAttributeOptionRelation/quoteAttributeSpecialComponent.js'></script>");
// 引入选项特规组件
document.write("<script type='text/javascript' src='/statics/js/modules/quoteProductAttributeOptionRelation/quoteOptionSpecialComponent.js'></script>");

var vm = new Vue({
    el: '#rrapp',
    data: {
        activeName: 'first',
        attributeSpecial: {
            showList: true,//属性列表显示/ false 显示详情
            queryParams: {categoryName: null, partsName: null, attributeName: null},//属性特规查询参数
            page: {currentPage: 0, pageSizes: [15, 30, 100], pageSize: 15, total: 0, ascending: [], descending: []},//属性特规分页参数
            specialData: [],//属性特规参数列表
            isAdd:{},//0新增 1编辑
            id: {},//编辑行id

        },
        optionSpecial: {
            showList: true,//属性列表显示/ false 显示详情
            queryParams: {categoryName: null, partsName: null, optionName: null},//选项特规查询参数
            page: {currentPage: 0, pageSizes: [15, 30, 100], pageSize: 15, total: 0, ascending: [], descending: []},//选项特规分页参数
            specialData: [],//选项特规参数列表
            isAdd:{},//0新增 1编辑
            id: {},//编辑行id
        },

    },
    mounted: function () {
        this.search();
    },

    methods: {
        //tab 页切换
        handleClick: function (tab, event) {
            if (tab.name == 'first') { //属性特规
                this.queryMethod();
            }
            if (tab.name == 'second') { //选项特规
                this.queryOptionSpecialMethod();
            }
        },
        /*==================属性特规方法 Start==================*/

        // 属性特规页数变化
        handleAttributeSizeChange: function (val) {
            this.attributeSpecial.page.pageSize = val;
            this.queryMethod();
        },
        //属性特规页变化
        handleAttributeCurrentChange: function (val) {
            this.attributeSpecial.page.currentPage = val;
            this.queryMethod();
        },

        search: function () {
            this.attributeSpecial.page.currentPage = 0;
            this.queryMethod();
        },

        queryMethod: function () {
            //查询参数
            var queryParam = this.attributeSpecial.queryParams;

            // 分页参数
            queryParam.page = this.attributeSpecial.page.currentPage;
            queryParam.limit = this.attributeSpecial.page.pageSize;


            //ajax 请求
            $.ajax({
                type: "POST",
                url: baseURL + "quoteProductAttributeOptionRelation/quoteproductattributeoptionrelation/queryAttributeSpecialList",
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(queryParam),
                success: function (r) {
                    if (r.code == 0) {
                        vm.attributeSpecial.page.total = r.page.totalCount;
                        vm.attributeSpecial.specialData = r.page.list;
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },

        // 添加属性特规
        addAttributeSpecial: function () {
            this.attributeSpecial.showList = false;
            this.attributeSpecial.isAdd = 0;
            this.$refs.zyAttributeSpecial.addAttributeSpecial();
        },

        goBackAttribute: function () {
            //情况编辑部分数据
            this.attributeSpecial.showList = true;
            this.attributeSpecial.isAdd = {};
            this.attributeSpecial.id={};
            this.queryMethod();
        },

        //编辑属性特规
        handleEditAttributeSpecial: function (id) {
            this.attributeSpecial.showList = false;
            this.attributeSpecial.isAdd = 1;
            this.attributeSpecial.id = id;
            this.$refs.zyAttributeSpecial.handleEditAttributeSpecial(id);

        },

        /*==================选项特规方法 Start==================*/
        // 选项特规页数变化
        handleOptionSizeChange: function (val) {
            this.optionSpecial.page.pageSize = val;
            this.queryOptionSpecialMethod();
        },
        //属性特规页变化
        handleOptionCurrentChange: function (val) {
            this.optionSpecial.page.currentPage = val;
            this.queryOptionSpecialMethod();
        },

        searchOptionSpecial: function () {
            this.optionSpecial.page.currentPage = 0;
            this.queryOptionSpecialMethod();
        },

        queryOptionSpecialMethod: function () {
            //查询参数
            var queryParam = this.optionSpecial.queryParams;

            // 分页参数
            queryParam.page = this.optionSpecial.page.currentPage;
            queryParam.limit = this.optionSpecial.page.pageSize;


            //ajax 请求
            $.ajax({
                type: "POST",
                url: baseURL + "quoteProductAttributeOptionRelation/quoteproductattributeoptionrelation/queryOptionSpecialList",
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(queryParam),
                success: function (r) {
                    if (r.code == 0) {
                        vm.optionSpecial.page.total = r.page.totalCount;
                        vm.optionSpecial.specialData = r.page.list;
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },

        // 添加选项、特规
        addOptionSpecial : function () {
            this.optionSpecial.showList = false;
            this.optionSpecial.isAdd = 0;
            this.$refs.zyOptionSpecial.addOptionSpecial();
        },

        goBackOption: function () {
            //情况编辑部分数据
            this.optionSpecial.showList = true;
            this.optionSpecial.isAdd = {};
            this.optionSpecial.id={};
            this.queryOptionSpecialMethod();
        },

        //编辑属性特规
        handleEditOptionSpecial: function (id) {
            this.optionSpecial.showList = false;
            this.optionSpecial.isAdd = 1;
            this.optionSpecial.id = id;
            this.$refs.zyOptionSpecial.handleEditOptionSpecial(id);

        },

    }
});